/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2022-01-26 10:17:18
 * @LastEditors: GGB
 * @LastEditTime: 2022-01-26 14:05:01
 */
import { FormSchema } from '/@/components/Form';

export const formSchema: FormSchema[] = [
  {
    field: 'user_name',
    label: '用户名',
    component: 'Input',
    required: true,
  },
  {
    field: 'password',
    label: '当前密码',
    component: 'InputPassword',
    required: true,
  },
  {
    field: 'confirmPassword',
    label: '确认密码',
    component: 'InputPassword',
    dynamicRules: ({ values }) => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (!value) {
              return Promise.reject('不能为空');
            }
            if (value !== values.password) {
              return Promise.reject('两次输入的密码不一致!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
];
